// 消息类型
export interface WebSocketMessage {
  sender_id: string
  status: number
  content: string
  type:
    | 'text'
    | 'image'
    | 'file'
    | 'friendRequest'
    | 'friendResponse'
    | 'error'
    | 'ok'
    | 'FRIEND_REQUEST_SUCCESS'
    | 'NEW_FRIEND_REQUEST'
    | 'OFFLINE_MESSAGE'
    | 'FRIEND_ACCEPT'
  timestamp?: number // 可选字段，客户端发送时可以不提供
  data?: any // 可选字段，根据消息类型存储额外数据
}

// 连接状态类型
export type ConnectionStatus =
  | '未连接'
  | '连接中'
  | '已连接'
  | '已断开'
  | '连接失败'
  | '连接错误'

// 配置选项
export interface WebSocketOptions {
  url: string
  maxReconnectAttempts?: number
  reconnectInterval?: number
  heartbeatInterval?: number
  onMessage?: (msg: WebSocketMessage) => void
  onStatusChange?: (status: ConnectionStatus) => void
  onError?: (err: Event) => void
  options?: {}
}

// 消息类型
export type MessageType = 'sent' | 'received' | 'read'
